#include<iostream>
#include<cstring>
using namespace std;

string str[6] = {"in", "input", "out", "output", "integer", "tiger"};
string s;
int dp[1000010];

bool check(int x, string sx) {
    for(int i=sx.length()-1; i>=0; i--) {
        if(sx.at(i) != s.at(x-sx.length()+i+1))
            return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    while(n-->0) {
        memset(dp, false, sizeof(dp));
        dp[0] = true;
        cin >> s;
        for(int i=1; i<=s.length(); i++) {
            char c = s.at(i-1);
            if(c!='i' && c!='n' && c!='p' && c!='u' && c!='t'
            && c!='o' && c!='e' && c!='g' && c!='r')    break;
            for(int j=0; j<6; j++) {
                if(i < str[j].length()) continue;
                if(dp[i])    break;
                if(check(i-1, str[j]))
                    dp[i] = dp[i-str[j].length()];
            }
        }
        if(dp[s.length()])  cout << "YES" << endl;
        else cout << "NO" << endl;
        // for(int i=0; i<=s.length(); i++) {
        //     cout << dp[i] << "    ";
        // }
        // cout << endl;
    }
    return 0;
}